package com.itgungnir.designpattern.iterator;

import java.util.List;

/**
 * Animal集合的迭代器
 */
public class AnimalIterator implements Iterator {
	private List<String> animals;
	private int currentPosition;

	public AnimalIterator(List<String> animals) {
		this.animals = animals;
		this.currentPosition = -1;
	}

	@Override
	public boolean hasNext() {
		return currentPosition < animals.size() - 1;
	}

	@Override
	public Object next() {
		return animals.get(++currentPosition);
	}
}